package com.example.webdome.util;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.webdome.mapper.UserMapper;
import com.example.webdome.pojo.User;
import com.xiaoleilu.hutool.json.JSONUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
@Component
public class userIdUtils {
    @Resource
    private UserMapper userMapper;
    public  Integer getUserId(String email){
        QueryWrapper<User> Wrapper = new QueryWrapper<>();
        QueryWrapper<User> eq = Wrapper.eq("email", email);
        List<User> list = userMapper.selectList(eq);
        String json = JSONUtil.toJsonStr(list);
        User u = JSONObject.parseObject(json, User.class);
        return u.getId();
    }
}
